﻿<html xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    
    <meta name="save" content="history" />
    <meta name="Language" content="en-us" />
    <meta name="System.Keywords" content="branching, process guidance" />
    <meta name="Microsoft.Help.Id" content="f586f036-a63f-40f9-8143-732e1d01323f" />
    <meta name="Description" content="Source code is an important asset in your development effort. But it can be a challenge to effectively manage and evolve source files when multiple developers work concurrently on file updates." />
    <meta name="Microsoft.Help.ContentType" content="Concepts" />
    <meta name="DCSext.ProductFamily" content="LIB_DG" />
    <meta name="DCSext.Product" content="ALM_TeamFoundation" />
    <meta name="DCSext.Title" value="Branch Strategically" />
    <link rel="stylesheet" type="text/css" href="../styles/presentation.css" />
    
    <script type="text/javascript" src="../scripts/EventUtilities.js"> </script>
    <script type="text/javascript" src="../scripts/SplitScreen.js"> </script>
    <script type="text/javascript" src="../scripts/Dropdown.js"> </script>
    <script type="text/javascript" src="../scripts/script_manifold.js"> </script>
    <script type="text/javascript" src="../scripts/script_feedBack.js"> </script>
    <script type="text/javascript" src="../scripts/CheckboxMenu.js"> </script>
    <script type="text/javascript" src="../scripts/CommonUtilities.js"> </script>
    <xml><MSHelp:Keyword Index="A" Term="f586f036-a63f-40f9-8143-732e1d01323f" /><MSHelp:Keyword Index="K" Term="branching, process guidance" /><MSHelp:Attr Name="RevisionNumber" Value="18" /><MSHelp:Attr Name="AssetID" Value="f586f036-a63f-40f9-8143-732e1d01323f" /><MSHelp:Attr Name="Abstract" Value="Source code is an important asset in your development effort. But it can be a challenge to effectively manage and evolve source files when multiple developers work concurrently on file updates. You can use a version control system to store source cod ..." /><MSHelp:Attr Name="CommunityContent" Value="1" /><MSHelp:Attr Name="ShippedIn" Value="vs.90" /><MSHelp:Attr Name="TopicVersion" Value="10.0.10236.10000" /><MSHelp:Attr Name="Catalog Container" Value="System_Default_Catalog" /><MSHelp:Attr Name="Content Set Container" Value="System_Default_Content_Set" /><MSHelp:Attr Name="TopicType" Value="kbArticle" /><MSHelp:Attr Name="Locale" Value="en-us" /></xml>
    <title>Branch Strategically</title>
</head>
<body>
	<input type="hidden" id="userDataCache" class="userDataStyle" />
	<input type="hidden" id="hiddenScrollOffset" />
	<img id="collapseImage" style="display:none; height:0; width:0;" src="../icons/collapse_all.gif" alt="Collapse image" title="Collapse image" />
	<img id="expandImage" style="display:none; height:0; width:0;" src="../icons/expand_all.gif" alt="Expand Image" title="Expand Image" />
	<img id="collapseAllImage" style="display:none; height:0; width:0;" src="../icons/collapse_all.gif" />
	<img id="expandAllImage" style="display:none; height:0; width:0;" src="../icons/expand_all.gif" />
	<img id="dropDownImage" style="display:none; height:0; width:0;" src="../icons/dropdown.gif" />
	<img id="dropDownHoverImage" style="display:none; height:0; width:0;" src="../icons/dropdownHover.gif" />
	<img id="copyImage" style="display:none; height:0; width:0;" src="../icons/copycode.gif" alt="Copy image" title="Copy image" />
	<img id="copyHoverImage" style="display:none; height:0; width:0;" src="../icons/copycodeHighlight.gif" alt="CopyHover image" title="CopyHover image" />
	<div id="header">
		<table id="topTable" cellspacing="0" cellpadding="0">
			<tr>
				<td>
					<span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage, event)" tabindex="0">
						<img ID="toggleAllImage" class="toggleAll" src="../icons/collapse_all.gif" /> 
						<label id="collapseAllLabel" for="toggleAllImage" style="display: none;">Collapse All</label>
						<label id="expandAllLabel" for="toggleAllImage" style="display: none;">Expand All</label> 
					</span> 
					<span>    </span> 
					<span id="devlangsDropdown" class="filter" tabindex="0">
						<img id="devlangsDropdownImage" src="../icons/dropdown.gif" /> 
						<label id="devlangsMenuAllLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: All </nobr></label>
						<label id="devlangsMenuMultipleLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: Multiple </nobr></label>
						<label id="devlangsMenuVisualBasicLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: Visual Basic </nobr></label>
						<label id="devlangsMenuCSharpLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: C# </nobr></label>
						<label id="devlangsMenuManagedCPlusPlusLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: Visual C++ </nobr></label>
						<label id="devlangsMenuFSharpLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: F# </nobr></label>
						<label id="devlangsMenuJScriptLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: JScript </nobr></label>
					</span> 
				</td>
			</tr>
		</table>
		<div id="devlangsMenu">
			<input id="VisualBasicCheckbox" type="checkbox" data="VisualBasic,vb,'persist'" value="on" onClick="SetLanguage(this)" />
			<label class="checkboxLabel" for="VisualBasicCheckbox">Visual Basic</label><br />
			<input id="CSharpCheckbox" type="checkbox" data="CSharp,cs,'persist'" value="on" onClick="SetLanguage(this)" />
			<label class="checkboxLabel" for="CSharpCheckbox">C#</label><br />
			<input id="ManagedCPlusPlusCheckbox" type="checkbox" data="ManagedCPlusPlus,cpp,'persist'" value="on" onClick="SetLanguage(this)" />
			<label class="checkboxLabel" for="ManagedCPlusPlusCheckbox">Visual C++</label><br />
			<input id="FSharpCheckbox" type="checkbox" data="FSharp,fs,'persist'" value="on" onClick="SetLanguage(this)" />
			<label class="checkboxLabel" for="FSharpCheckbox">F#</label><br />
			<input id="JScriptCheckbox" type="checkbox" data="JScript,cs,'persist'" value="on" onClick="SetLanguage(this)" />
			<label class="checkboxLabel" for="JScriptCheckbox">JScript</label><br />
		</div>
		<table id="bottomTable" cellpadding="0" cellspacing="0">
			<tr id="headerTableRow1">
				<td align="left">
					<span id="runningHeaderText"> </span> 
				</td>
			</tr>
			<tr id="headerTableRow2">
				<td align="left">
					<span id="nsrTitle">Branch Strategically</span></td>
			</tr>
			<tr id="headerTableRow3">
				<td align="left">
					<span id="headfeedbackarea" class="feedbackhead">
						<a href="javascript:SubmitFeedback('bjordan@microsoft.com','','','10.0','10.0.10236.10000','%0\dThank%20you%20for%20your%20feedback.%20The%20GovDev%20team%20uses%20your%20feedback%20to%20improve%20documentation.%20While%20we%20are%20reviewing%20your%20feedback,%20we%20may%20send%20you%20e-mail%20to%20ask%20for%20clarification%20or%20feedback%20on%20a%20solution.%20We%20do%20not%20use%20your%20e-mail%20address%20for%20any%20other%20purpose%20and%20we%20delete%20it%20after%20we%20finish%20our%20review.%0\AFor%20further%20information%20about%20the%20privacy%20policies%20of%20Microsoft,%20please%20see%20http://privacy.microsoft.com/en-us/default.aspx.%0\A%0\d','Customer%20Feedback');">
							Send Feedback
						</a>
					</span> 
				</td>
			</tr>
		</table>
		<table id="gradientTable">
			<tr>
				<td class="nsrBottom" background="../icons/gradient.gif" />
			</tr>
		</table>
	</div>
    <div id="mainSection">
        <div id="mainBody">
            <div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()" />
            <font color="DarkGray"><p /></font>
            <div class="introduction">
                <p>Source code is an important asset in your development effort. But it can be a challenge
                    to effectively manage and evolve source files when multiple developers work concurrently
                    on file updates. You can use a version control system to store source code in shared
                    repositories, to isolate parallel development efforts, to integrate code changes,
                    and to recover previous file versions. A key element in version control is branching
                    that enables simultaneous development. If you branch strategically, you can maintain
                    the order and consistency of multiple versions of your software.</p>
                <p>Team Foundation provides a flexible and reliable version control system. You can
                    use Team Foundation version control to manage multiple revisions during development
                    of source code, documents, work items, and other critical information that is worked
                    on by your team. For more information about version control in Visual Studio Team
                    Foundation Server, see <span sdata="link"><a href="http://msdn.microsoft.com/library/33267cee-fe5f-4aa3-b2cd-6d22ceace314">
                        Using Version Control</a></span>. </p>
            </div>
            <h1 class="heading"><span onclick="ExpandCollapse(sectionToggle0)" style="cursor: default;"
                onkeypress="ExpandCollapse_CheckKey(sectionToggle0, event)" tabindex="0">
                <img id="sectionToggle0" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />How
                does your team manage code while it introduces multiple changes simultaneously through
                several project releases?</span> </h1>
            <div id="sectionSection0" class="section" name="collapseableSection" style="">
                <p>When you work with a version control system, you must consider how to set up a branch
                    structure. You can create a branch by mirroring the source code file. Then you can
                    change the branch without affecting the source. For example, as the branch structure
                    in the following illustration shows, the MAIN branch contains completed functionality
                    that has passed integration tests, and the DEVELOPMENT branch contains the code
                    that is under construction. When a new functionality in the DEVELOPMENT branch is
                    completed and can pass integration tests, you can promote the code from the DEVELOPMENT
                    branch to the MAIN branch. This process is referred to as reverse integration. Conversely,
                    if you merge the code from the MAIN branch to the DEVELOPMENT branch, the process
                    is referred to as forward integration. </p>
                <img alt="Main Branch" src="../art/BranchStrat_Main.png" /><p>For more information about
                    how to create and merge code branches, see the following page on the CodePlex Web
                    site: <a href="http://go.microsoft.com/fwlink/?LinkId=178567">Team Foundation Server
                        Branching Guide 2.0</a>.</p>
                <p>Branching and merging entail the following principles:</p>
                <ol>
                    <li>
                        <p>Each branch must have a defined policy about how to integrate code into this branch.
                            For example, in the branch structure of the previous illustration, you can assign
                            a team member to own and manage the MAIN branch. This member is responsible for
                            performing the initial branch operation, reverse integrating changes from the DEVELOPMENT
                            branch to the MAIN branch, and forward integrating changes from the MAIN branch
                            to the DEVELOPMENT branch. Forward integration is important when the MAIN branch
                            also integrates changes from other branches. </p>
                    </li>
                    <li>
                        <p>The MAIN branch must contain code that has passed integration tests so that it is
                            always ready for a release.</p>
                    </li>
                    <li>
                        <p>The DEVELOPMENT (or work) branch constantly evolves because team members check in
                            changes periodically.</p>
                    </li>
                    <li>
                        <p>Labels are snapshots of the files in a branch at a specific time.</p>
                        <p>For more information, see <span sdata="link"><a href="http://msdn.microsoft.com/library/8945006e-3a03-4ae1-b5a1-79be57610321">
                            Use Labels to Take a Snapshot of Your Files</a></span>. </p>
                    </li>
                </ol>
                <p>Team Foundation Build allows you to choose from several types of builds for your
                    branches: manual, continuous, gated, rolling, and scheduled. We recommend that the
                    MAIN branch has a gated check-in build type. This means that the DEVELOPMENT branch
                    must pass all requirements for the MAIN branch before you can commit a reverse integration.
                    The DEVELOPMENT branch should run a continuous build type because your team must
                    know as soon as possible when a new check-in affects the DEVELOPMENT branch.
                </p>
            </div>
            <h1 class="heading"><span onclick="ExpandCollapse(sectionToggle1)" style="cursor: default;"
                onkeypress="ExpandCollapse_CheckKey(sectionToggle1, event)" tabindex="0">
                <img id="sectionToggle1" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />How
                often should your team reverse integrate and forward integrate?</span> </h1>
            <div id="sectionSection1" class="section" name="collapseableSection" style="">
                <p>As shown in the following illustration, reverse integration and forward integration
                    should occur at least when you complete a use case. Although each team might define
                    completeness differently, completion of a use case generally means that you complete
                    both the functionality and the corresponding unit tests. You can reverse integrate
                    to the MAIN branch only after unit tests have verified the stability of the DEVELOPMENT
                    branch.</p>
                <img alt="Branch across two sprints" src="../art/BranchStrat_Sprint.png" /><p>If you
                    have more than one work (DEVELOPMENT) branch, forward integration to all work branches
                    should occur as soon as any branch integrates into the MAIN branch. Because the
                    MAIN branch is kept stable, forward integration is safe. Conflicts or failures at
                    the work branches might occur because you cannot guarantee that the work branches
                    are stable. </p>
                <p>It is important that you resolve all conflicts as soon as possible. By using a gated
                    check-in for the MAIN branch, you help make the reverse integration much easier
                    because quality gates help avoid conflicts or errors in the MAIN branch. For more
                    information, see <span sdata="link"><a href="http://msdn.microsoft.com/library/28fabf92-d3e0-43bb-96b5-7e5c10baa336">
                        Check In Pending Changes that Are Controlled by a Gated Check-in Build</a></span>.</p>
            </div>
            <h1 class="heading"><span onclick="ExpandCollapse(sectionToggle2)" style="cursor: default;"
                onkeypress="ExpandCollapse_CheckKey(sectionToggle2, event)" tabindex="0">
                <img id="sectionToggle2" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />How
                does your team manage sources that implement different use cases?</span> </h1>
            <div id="sectionSection2" class="section" name="collapseableSection" style="">
                <p>As the following illustration shows, you can check in changes to a work branch 
                    periodically to complete a use case. You can implement multiple use cases in the 
                    same branch at the same time. However, you can reverse integrate to the MAIN 
                    branch only when you complete all the in-progress work. It is recommended that 
                    you group use cases by similar size because you do not want a large use case to 
                    block the integration of many small ones. You can split the two sets of use 
                    cases into two branches.</p>
                <img alt="Check-in Completes Use Case" src="../art/BranchStrat_UseCase.png" />
            </div>
            <h1 class="heading"><span onclick="ExpandCollapse(sectionToggle3)" style="cursor: default;"
                onkeypress="ExpandCollapse_CheckKey(sectionToggle3, event)" tabindex="0">
                <img id="sectionToggle3" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />When
                should the team add a branch?</span> </h1>
            <div id="sectionSection3" class="section" name="collapseableSection" style="">
                <p>You should create branches in the following situations:</p>
                <ul>
                    <li>
                        <p>When you must release code on a different schedule/cycle than the existing branches.
                        </p>
                    </li>
                    <li>
                        <p>When your code requires a different branch policy. If you create a new branch that
                            has the new policy, you can add strategic value to your project.</p>
                    </li>
                    <li>
                        <p>When functionality is released to a customer and your team plans to make changes
                            that do not affect the planned release cycle.</p>
                    </li>
                </ul>
                <p>You should not create a branching for each use case because it creates a high integration
                    cost. Although Team Foundation Server 2010 makes branching easy, the overhead of
                    managing branches can become significant if you have many branches.</p>
            </div>
            <h1 class="heading"><span onclick="ExpandCollapse(sectionToggle4)" style="cursor: default;"
                onkeypress="ExpandCollapse_CheckKey(sectionToggle4, event)" tabindex="0">
                <img id="sectionToggle4" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />How
                does the team manage releases from the version control perspective?</span> </h1>
            <div id="sectionSection4" class="section" name="collapseableSection" style="">
                <p>Your team should be able to release code at the end of any sprint. By using Team
                    Foundation Server, you can label a branch to take a snapshot of the code at a specific
                    point in time. As the following illustration shows, you can label the MAIN branch
                    for a release. This lets you return the branch to its state at this point. </p>
                <img alt="Label a branch to take a snapshot of the code" src="../art/BranchStrat_Label.png" /><p>
                    Because you must implement updates on releases, creating a branch for a release
                    helps your team continue to work independently on the next sprint without creating
                    conflicts with future releases. The following illustration shows a branch that contains
                    code for an update and that is reverse integrated into the MAIN branch after a release
                    at the end of the second sprint.</p>
                <img alt="Reverse integrate a branch that contains update" src="../art/BranchStrat_Hotfix.png" /><p>
                    When you create a branch for a release, you should create that branch from the MAIN
                    branch, which is the most stable. If you branch for release from a work branch,
                    it can cause integration challenges because the stability of work branches is not
                    guaranteed.</p>
            </div>
        </div>
        <div id="footer">
            <div class="footerLine">
                <img width="100%" height="3px" src="../icons/footer.gif" alt="Footer image" title="Footer image" />
            </div>
             <span id="feedbackarea">Send <a href="javascript:SubmitFeedback('bjordan@microsoft.com','','','10.0','10.0.10236.10000','%0\dThank%20you%20for%20your%20feedback.%20The%20GovDev%20team%20uses%20your%20feedback%20to%20improve%20documentation.%20While%20we%20are%20reviewing%20your%20feedback,%20we%20may%20send%20you%20e-mail%20to%20ask%20for%20clarification%20or%20feedback%20on%20a%20solution.%20We%20do%20not%20use%20your%20e-mail%20address%20for%20any%20other%20purpose%20and%20we%20delete%20it%20after%20we%20finish%20our%20review.%0\AFor%20further%20information%20about%20the%20privacy%20policies%20of%20Microsoft,%20please%20see%20http://privacy.microsoft.com/en-us/default.aspx.%0\A%0\d','Customer%20Feedback');">
                feedback </a>on this topic or submit an issue at the GovDev for TFS Codeplex Site.</span> 
        </div>
    </div>
</body>
</html>
